// pages/companyApprove1/companyApprove1.js

const app = getApp()
const pathUrl = app.globalData.pathUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    proAry: ['企业验证', '发起公证', '活体检测', '签署完成'],
    agree: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    var that = this;
    var orderNo = wx.getStorageSync('orderNo')
    var userId = wx.getStorageSync('userId')
    var telphone = wx.getStorageSync('telphone')
    that.setData({
      orderNo: orderNo,
      userId: userId,
      telphone: telphone,
    })
    this.getList03();
    // this.getCorporateBankList();
  },
  getList03: function () {
    var that = this;
    var orderNo = that.data.orderNo;
    wx.request({
      url: pathUrl + '/gzgl/fxyGzgl03/list',
      method: 'GET',
      data: {
        query07: orderNo,
      },
      success: function (res) {
        console.log(res);
        var list = res.data.result.records[0]
        console.log(list)
        wx.setStorageSync("userId1", list.query24)
        that.setData({
          companyName: list.query12,
          code: list.query13,
          companyName1: list.query12,
          userId1: list.query24
          // bankCode: list.query20,
          // bankName: list.query20,
          // bankId: list.query20
        })
      },
      fail: function (res) { }
    });
  }, 

  goSub: function () {
    var that = this;
    var userId = that.data.userId1;
    var orderAmount = that.data.orderAmount;
    var mobCode = that.data.mobCode;
    if (orderAmount == null || orderAmount ==''){
      wx.showModal({
        title: '提示',
        content: '请填写打款金额',
        showCancel:false
      })
      return false
    }
    if (mobCode == null || mobCode == '') {
      wx.showModal({
        title: '提示',
        content: '请填写验证码',
        showCancel: false
      })
      return false
    }
    var data = {
      userId: userId,
      orderAmount: orderAmount,
      mobCode: mobCode,
    }
    console.log(data)
    wx.request({
      url: pathUrl + '/fxy/1/doEnterpriseRealnameVerification',
      method: 'POST',
      data: data,
      success: function (res) {
          if(res.data.code =='500'){
            wx.showModal({
              title: '提示',
              content: res.data.message,
              showCancel: false,
            })
            return false
          }
          if(res.data.code =='200'){
            wx.showModal({
              title: '提示',
              content: '企业已经通过实名认证',
              showCancel:false,
              success(res){
                if(res.confirm){
                  wx.reLaunch({
                    url: '/pages/index/index',
                  })
                }
              }
            })
          }
        console.log(res.data.message)
        // wx.navigateTo({
        //   url: '../notificationbook/notificationbook',
        // })
        // if (res.data.success) { // 登陆成功
        //   wx.setStorageSync('loginInfo', JSON.stringify(res.data.result));
        //   wx.navigateTo({
        //     url: "/pages/index/index"
        //   })
        // } else { // 登陆失败
        //   wx.showToast({
        //     title: res.data.message,
        //     icon: 'fail',
        //     duration: 1000
        //   });
        // }
      },
      fail: function (res) { }
    });
  },
  getCorporateBankList: function () {
    var that = this;
    var orderNo = that.data.orderNo;
    wx.request({
      url: pathUrl + '/fxy/1/getCorporateBankList',
      data: {
        userId: '123'
      },
      method: 'POST',
      success: function (res) {
        console.log(res);
        console.log(JSON.parse(res.data.message).resultData.bankInfos)
        var bankInfo = JSON.parse(res.data.message).resultData.bankInfos;
        that.setData({
          array: bankInfo
        })
        // var list = res.data.result.records[0]
        // console.log(list)
        // that.setData({
        //   companyName: list.query12,
        //   code: list.query13,
        //   companyName1: list.query12,
        //   // bankCode: list.query20,
        //   // bankName: list.query20,
        //   // bankId: list.query20
        // })
      },
      fail: function (res) { }
    });
  },
  companyNameInput: function (e) {
    this.setData({
      companyName: e.detail.value
    })
  },
  codeInput: function (e) {
    this.setData({
      code: e.detail.value
    })
  },
  companyName1Input: function (e) {
    this.setData({
      companyName1: e.detail.value
    })
  },
  bankCodeInput: function (e) {
    this.setData({
      bankCode: e.detail.value
    })
  },
  bankNameInput: function (e) {
    this.setData({
      bankName: e.detail.value
    })
  },
  bankIdInput: function (e) {
    this.setData({
      bankId: e.detail.value
    })
  },
  orderAmountInput: function (e) {
    this.setData({
      orderAmount: e.detail.value
    })
  },
  mobCodeInput: function (e) {
    this.setData({
      mobCode: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})